<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>修改密码</title>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <script src="js/jquery-3.4.0.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
</head>
<style>
    .sidebar {
        position: fixed;
        top: 51px;
        bottom: 0;
        left: 0;
        z-index: 1000;
        display: block;
        padding: 20px;
        overflow-x: hidden;
        overflow-y: auto;
        background-color: #f5f5f5;
        border-right: 1px solid #eee;
    }
    /*.nav-sidebar {
        margin-right: -21px;
        margin-bottom: 20px;
        margin-left: -20px;
    }*/
    .main1 {
        padding-right: 50px;
        padding-left: 50px;
    }
    .main1{
        padding: 50px;
    }
    .border-bottom{
        border-bottom: 1px solid #dee2e6 !important;
    }
    .footer{
        height: 30px;
        width: 100%;
        background-color: #f5f5f5;
    }
    .footnote{
        height: 30px;
        line-height: 30px;
        width: 100px;
        margin-left: auto;
        margin-right: auto;
    }
</style>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
    <div class="container-fluid">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="/Student">TCES</a>
        </div>
        <div id="navbar" class="navbar-collapse collapse in" aria-expanded="true" style="height:1px;">
            <ul class="nav navbar-nav navbar-right">
                <li>
                    <a href="#">&nbsp;<span class="glyphicon glyphicon-user" aria-hidden="true"></span>&nbsp;&nbsp;教师&nbsp;&nbsp;:</a>
                </li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown"><span name="UserName" th:text="${session.userName}"></span>&nbsp;&nbsp;<strong class="caret"></strong></a>
                    <ul class="dropdown-menu">
                    <li><a href="#" th:text="'工号:'+${session.userId}"></a></li>
                        <li>
                            <a href="/Logout">退出</a>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
</nav>
<div class="container-fluid">
    <div class="row">
        <div class="col-sm-3 col-md-2 sidebar">
            <ul class="nav nav-sidebar">
                <li class="active" id="KC">
                    <a href="/TeacherCourse">
                        &nbsp;<span class="glyphicon glyphicon-search" aria-hidden="true" ></span>&nbsp;&nbsp;&nbsp;我的课程
                        <span class="sr-only">(current)</span>
                    </a>
                </li>
                
                <li id="CF">
                    <a href="/TeacherScore">&nbsp;<span class="glyphicon glyphicon-heart-empty" aria-hidden="true" ></span>&nbsp;&nbsp;&nbsp;查看评价分数</a>
              	</li >

                <li id="PJ">
                    <a href="/TeacherPJ">&nbsp;<span class="glyphicon glyphicon-heart-empty" aria-hidden="true" ></span>&nbsp;&nbsp;&nbsp;同行评价</a>
                </li >
                <li id="MM"><a href="#">&nbsp;<span class="glyphicon glyphicon-cog" aria-hidden="true" ></span>&nbsp;&nbsp;&nbsp;修改密码</a></li>
            </ul>
        </div>





        修改密码
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main1" id="RP" >
            <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
                <h1 class="h2">修改密码</h1>
            </div>
            <form action="#">
                <div class="form-group">
                    <label for="id">教师工号:</label>
                    <span class="form-control" name="userId" readonly disabled  th:text="${session.userId}"></span>
                </div>
                <div class="form-group">
                    <label for="username">姓名：</label>
                    <span class="form-control" readonly disabled  th:text="${session.userName}"></span>
                </div>
                <div class="form-group">
                    <label for="pwd">新密码:</label>
                    <input type="password" name="newPassword" class="form-control" id="pwd" placeholder="请输入新密码">
                </div>
                <div class="form-group">
                    <label for="Rpwd">确认新密码:</label>
                    <input type="password" name="newPassword1" class="form-control" id="Rpwd" placeholder="请确认新密码">
                </div>
                <input type="button" class="btn btn-primary" value="更改密码" id="submit">
            </form>
        </div>
        <footer class="footer navbar-fixed-bottom ">
            <div class="footnote">
                第4小组作品
            </div>
        </footer>
    </div>
</div>

<!-- js -->
<script>
    /*修改密码*/
    $(function () {

        $("#submit").on("click",function(){
            var userId = $("span[name='userId']").text();
            var newPassword = $("input[name='newPassword']").val();
            var newPassword1 = $("input[name='newPassword1']").val();
            if(newPassword == newPassword1){
                $.ajax({
                    type:"post",
                    url:"/TchCGPW",
                    datatype:"json",
                    async:false,
                    data: {
                        "tchId":userId,
                        "password":newPassword
                    },
                    success:function(data){
                        if( data.msg == "成功"){
                            alert("密码修改成功，请重新登录!");
                            window.location.href = "/Logout";
                        }
                    }

                });
            }else{
                alert("两次输入的密码不相同!");
                $("#pwd").val("");
                $("#Rpwd").val("");
            }


        })

    })
</script>
</body>
</html>

</body>
</html>